//
//  PhotoTypeSelectTableViewController.m
//  PrintFamily
//
//  Created by edaihua on 16/3/21.
//  Copyright © 2016年 ___PrintFactory___. All rights reserved.
//

#import "PhotoTypeSelectTableViewController.h"
#import "PhotoPickerCollectionViewController.h"
#import "PhotoTypeSelectTableViewCell.h"
#import "PFPrintManager.h"
#import "PFPhotoRectManager.h"
#import "PFOrder.h"

@interface PhotoTypeSelectTableViewController () <UITableViewDataSource, UITableViewDelegate>
@property (strong, nonatomic) IBOutlet UIButton *rightButton;
@property (strong, nonatomic) IBOutlet UIButton *leftButton;

@property (nonatomic, strong) PFOrder *order;

@end

@implementation PhotoTypeSelectTableViewController

static NSString * const reuseIdentifier = @"TypeSelectCell";

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self.navigationController.navigationBar setBarTintColor:[UIColor colorWithRed:103.0/255.0 green:103.0/255.0 blue:103.0/255.0 alpha:1.0]];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.rightButton];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.leftButton];

    
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 4;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    PhotoTypeSelectTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:reuseIdentifier forIndexPath:indexPath];
    
    cell.typeLabel.text = [PFPrintManager getPrintTypeStringWithPrintType:indexPath.row];
    
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [PFPrintManager setCurrentType:indexPath.row];
    
    // Pop Warning if there is already photo selected
    [PFPrintManager setCurrentType:indexPath.row];
    [self performSegueWithIdentifier:@"showPhotoPicker" sender:indexPath];
}

#pragma mark - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
    if ([segue.identifier isEqualToString:@"showPhotoPicker"]) {
        PhotoPickerCollectionViewController *photoPicker = segue.destinationViewController;
        photoPicker.rectManager = [[PFCommonRectManager alloc] initWithType:[PFPrintManager getCurrentType] boarder:[PFPrintManager getCurrentBoarder]];
        
    }
}

#pragma mark - button gesture


@end
